home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_pow_single_thermal_m.cog < prev    next >
Text File  |  1998-02-25  |  5KB  |  183 lines

  1. # Jedi Knight MOTHS Cog Script
  2. #
  3. # POW_SINGLE_THERMAL_M.COG
  4. #
  5. # POWERUP Script - single Thermal Detonator
  6. #
  7. # [YB, CYW, RF, SRS]
  8. #
  9. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  10.  
  11.  
  12. symbols
  13.  
  14. template    explode=+small_exp             local
  15.  
  16. thing       powerup                          local
  17. thing       player                           local
  18. thing       sender                           local
  19.  
  20. int         bin=4                            local
  21. sound       pickupsnd=thrmlpu2.wav           local
  22. sound       respawnsnd=Activate01.wav        local
  23. flex        amount                           local
  24.  
  25. int         autosel=-1                       local
  26. int         bin_contents=0                   local
  27. int         autopickup=0                     local
  28. int         damage                           local
  29.  
  30. message     created
  31. message     damaged
  32. message     touched
  33. message     taken
  34. message     respawn
  35. message     timer
  36.  
  37. end
  38.  
  39. # ========================================================================================
  40.  
  41. code
  42.  
  43. created:
  44.    SetThingUserData(GetSenderRef(), 30);     // set the initial user data (i.e. "health")
  45.    Return;
  46.  
  47. # ............................................................................................
  48.  
  49. touched:
  50.    if (GetWeaponBin(bin) == -1)
  51.       return;
  52.  
  53.    player = GetSourceRef();
  54.  
  55.    if (GetThingType(player) == 10)  // Can only be taken by players.
  56.    {
  57.       amount = GetInv(player, GetWeaponBin(bin));
  58.  
  59.       if (IsMulti() || (amount < GetInvMax(player, GetWeaponBin(bin))))
  60.       {
  61.          TakeItem(GetSenderRef(), -1);
  62.          call taken;
  63.       }
  64.    }
  65.  
  66.    Return;
  67.  
  68. # ........................................................................................
  69.  
  70. damaged:
  71.    damage = GetParam (0);
  72.    sender = GetSenderRef();
  73.  
  74.    // only take damage 33% of the time
  75.    if(rand() < 0.33)
  76.       return;
  77.  
  78.    // If it's already dead, don't allow any more damage.
  79.    if (!GetThingUserData (sender))
  80.       return;
  81.  
  82.    // see if this will cause the explosion
  83.    if (GetThingUserData (sender) <= damage)
  84.    {
  85.       SetThingUserData(sender, 0);
  86.  
  87.       // timer for base explosion
  88.       SetTimerEx ((Rand () * 0.5), sender, 1, 0);
  89.    }
  90.    else
  91.    {
  92.       SetThingUserData(sender, GetThingUserData (sender) - damage);
  93.    }
  94.  
  95.    ReturnEx (0);
  96.    return;
  97.  
  98. # ........................................................................................
  99.  
  100. taken:
  101.    if (GetWeaponBin(bin) == -1)
  102.       return;
  103.  
  104.    player = GetSourceRef();
  105.    powerup = GetSenderRef();
  106.  
  107. //    // If the object has been destroyed, don't award it to the player.
  108. //   if (!GetThingUserData (powerup))
  109. //    return;
  110.  
  111.    // Print("Thermal Detonator");
  112.    jkPrintUNIString(player, 205);
  113.  
  114.    // Do effects.
  115.    PlaySoundLocal(pickupsnd, 1, 0, 0);
  116.    AddDynamicTint(player, 0.0, 0.0, 0.2);
  117.  
  118.    // store the old bin contents
  119.    bin_contents = GetInv(player, GetWeaponBin(bin));
  120.  
  121.    // Increment powerup amount.
  122.    ChangeInv(player, GetWeaponBin(bin), 1.0);
  123.  
  124.    // Check for Auto Pickup
  125.    autopickup = GetAutoPickup();
  126.    if((autopickup & 1) && !(autopickup & 2)) // DANGEROUS
  127.    {
  128.       if(!bin_contents)
  129.       {
  130.          if(!((autopickup & 4) && (GetWeaponPriority(player, GetWeaponBin(GetCurWeapon(player)), 0) >= GetWeaponPriority(player, bin, 0))))
  131.          {
  132.             if(!((autopickup & 8) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
  133.             {
  134.                SelectWeapon(player, GetWeaponBin(bin));
  135.                Return;
  136.             }
  137.          }
  138.       }
  139.    }
  140.  
  141.    // Check for Auto Reload
  142.    if(GetAutoReload() & 1)
  143.    {
  144.       if(!bin_contents)
  145.       {
  146.          if(!((GetAutoReload() & 2) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
  147.          {
  148.             // Try to autoselect and see if the best weapon is the TD
  149.             autosel = AutoSelectWeapon(player, 2);
  150.             if(autosel == bin) SelectWeapon(player, GetWeaponBin(bin));
  151.          }
  152.       }
  153.    }
  154.  
  155.    Return;
  156.  
  157. # ........................................................................................
  158.  
  159. respawn:
  160.    SetThingUserData(GetSenderRef(), 30);     // set the initial user data (i.e. "health")
  161.    PlaySoundThingLocal(respawnsnd, GetSenderRef(), 0.6, 5.0, 10.0, 0);
  162.  
  163.    Return;
  164.  
  165. # ........................................................................................
  166.  
  167. timer:
  168.    sender = GetSenderId ();
  169.    damage = GetParam (0);
  170.  
  171.    powerup = CreateThingNR(explode, sender);
  172.  
  173.    // Since the user data is 0, the player won't actually be awarded this powerup.
  174.    TakeItem(sender, -1);
  175.    return;
  176.  
  177. end
  178.  
  179.  
  180.  
  181.  
  182.  
  183.